//
//  MainTabBarController.swift
//  SinaWeiBo_18
//
//  Created by apple on 15/10/6.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    @IBOutlet weak var mainTabBar: MainTabBar!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        loadChildControllers()
        
        mainTabBar.composeButton.addTarget(self, action: "didClickComposeButton", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    
    func didClickComposeButton(){
    
        print(__FUNCTION__)
    }
    
    func loadChildControllers(){
    
        
        
        loadChildController("Home", "首页", "tabbar_home")
        loadChildController("Message", "消息", "tabbar_message_center")
        loadChildController("Discover", "发现", "tabbar_discover")
        loadChildController("Profile", "我", "tabbar_profile")
        
    
    }
    
    //参数名前面加 _ 表示忽略
    func loadChildController(sbName: String, _ title: String,_ imageName: String){
    
        let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
        nav.topViewController?.title = title
        
        nav.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
  }
    

}
